package com.ruoyi.binance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.binance.domain.BinanceAPriceMonitoring;
import com.ruoyi.binance.service.IBinanceAPriceMonitoringService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 高买低卖Controller
 *
 * @author zq
 * @date 2025-08-14
 */
@RestController
@RequestMapping("/binance/aPrice")
public class BinanceAPriceMonitoringController extends BaseController
{
    @Autowired
    private IBinanceAPriceMonitoringService binanceAPriceMonitoringService;

    /**
     * 查询高买低卖列表
     */
    @PreAuthorize("@ss.hasPermi('binance:aPrice:list')")
    @GetMapping("/list")
    public TableDataInfo list(BinanceAPriceMonitoring binanceAPriceMonitoring)
    {
        startPage();
        List<BinanceAPriceMonitoring> list = binanceAPriceMonitoringService.selectBinanceAPriceMonitoringList(binanceAPriceMonitoring);
        return getDataTable(list);
    }

    /**
     * 导出高买低卖列表
     */
    @PreAuthorize("@ss.hasPermi('binance:aPrice:export')")
    @Log(title = "高买低卖", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BinanceAPriceMonitoring binanceAPriceMonitoring)
    {
        List<BinanceAPriceMonitoring> list = binanceAPriceMonitoringService.selectBinanceAPriceMonitoringList(binanceAPriceMonitoring);
        ExcelUtil<BinanceAPriceMonitoring> util = new ExcelUtil<BinanceAPriceMonitoring>(BinanceAPriceMonitoring.class);
        util.exportExcel(response, list, "高买低卖数据");
    }

    /**
     * 获取高买低卖详细信息
     */
    @PreAuthorize("@ss.hasPermi('binance:aPrice:query')")
    @GetMapping(value = "/{code}")
    public AjaxResult getInfo(@PathVariable("code") String code)
    {
        return success(binanceAPriceMonitoringService.selectBinanceAPriceMonitoringByCode(code));
    }

    /**
     * 新增高买低卖
     */
    @PreAuthorize("@ss.hasPermi('binance:aPrice:add')")
    @Log(title = "高买低卖", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BinanceAPriceMonitoring binanceAPriceMonitoring)
    {
        return toAjax(binanceAPriceMonitoringService.insertBinanceAPriceMonitoring(binanceAPriceMonitoring));
    }

    /**
     * 修改高买低卖
     */
    @PreAuthorize("@ss.hasPermi('binance:aPrice:edit')")
    @Log(title = "高买低卖", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BinanceAPriceMonitoring binanceAPriceMonitoring)
    {
        return toAjax(binanceAPriceMonitoringService.updateBinanceAPriceMonitoring(binanceAPriceMonitoring));
    }

    /**
     * 删除高买低卖
     */
    @PreAuthorize("@ss.hasPermi('binance:aPrice:remove')")
    @Log(title = "高买低卖", businessType = BusinessType.DELETE)
    @DeleteMapping("/{codes}")
    public AjaxResult remove(@PathVariable String[] codes)
    {
        return toAjax(binanceAPriceMonitoringService.deleteBinanceAPriceMonitoringByCodes(codes));
    }
}
